﻿@page "/admin/vislog"
@using System.Linq.Expressions;
@using Microsoft.AspNetCore.Authorization;
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Core.Extension

@namespace ThingsGateway.Admin.Blazor
@attribute [Authorize]
@attribute [RolePermission]
@inject UserResoures UserResoures
@inherits BaseComponentBase


<MCard MinHeight=120 Rounded=true Elevation=1 Class="ma-2">
    <MCardSubtitle Class="text-subtitle-1">
        @AppService.I18n.T("周统计")
    </MCardSubtitle>
    <MDivider></MDivider>
    <MRow Class="pa-4" NoGutters Align="AlignTypes.Center" Justify="JustifyTypes.Start">

         <MECharts Option="eChartsOption" Width="@("100%")" MinHeight="300"></MECharts>

     </MRow>
 </MCard>



 <AppDataTable @ref="_datatable" TItem="SysVisitLog" SearchItem="VisitLogPageInput"
               AddItem="object" EditItem="object" IsShowSelect=false
               SearchModel="@_search" IsShowOperCol=false
               QueryCallAsync="QueryCallAsync"
                IsShowQueryButton IsShowSearchKey>
    <SearchTemplate>

        <MButton Color=@(_search.Category == CateGoryConst.Log_LOGIN ? "primary" : "white") Class="my-1 mx-2 "
                 OnClick="() => {if(_search.Category!=CateGoryConst.Log_LOGIN){_search.Category=CateGoryConst.Log_LOGIN;_datatable.QueryClickAsync();}}">
            @AppService.I18n.T("登录日志")
        </MButton>
        <MButton Color=@(_search.Category == CateGoryConst.Log_LOGOUT ? "primary" : "white") Class="my-1 mx-2 "
                 OnClick="() => {if(_search.Category!=CateGoryConst.Log_LOGOUT){_search.Category=CateGoryConst.Log_LOGOUT;_datatable.QueryClickAsync();}}">
            @AppService.I18n.T("登出日志")
        </MButton>



        <PDateTimePicker @bind-Value="context.StartTime"
                         TimeFormat="TimeFormat.Hr24"
                         ViewType="DateTimePickerViewType.Compact">
            <ActivatorContent Context="dt">
                <MTextField @bind-Value="context.StartTime" Label=@AppService.I18n.T(context.Description(x => x.StartTime))
                                    Clearable Class="my-1  mx-2 "
                                    Filled Outlined
                                    Readonly Dense
                             @attributes="@dt.Attrs">
                 </MTextField>
             </ActivatorContent>
             </PDateTimePicker>

             <PDateTimePicker @bind-Value="context.EndTime"
                              TimeFormat="TimeFormat.Hr24"
                              ViewType="DateTimePickerViewType.Compact">
             <ActivatorContent Context="dt">
                 <MTextField @bind-Value="context.EndTime" Label=@AppService.I18n.T(context.Description(x => x.EndTime))
                                    Clearable Class="my-1  mx-2 "
                                    Filled Outlined
                                    Readonly Dense
                             @attributes="@dt.Attrs">
                 </MTextField>
             </ActivatorContent>
             </PDateTimePicker>



             <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " Outlined
                     @bind-Value="context.Account" Label=@AppService.I18n.T(context.Description(x => x.Account)) />

     </SearchTemplate>
     <OtherToolbarTemplate>
         <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("SysVislogClear")) Color="error" Class="mx-2 my-1" OnClick=@(ClearClickAsync)>@AppService.I18n.T("清空")</MButton>
            <MMenu OffsetY Context="menu">
             <ActivatorContent>
                 <MButton @attributes="@menu.Attrs" Color="primary"
                          Class="my-1  mx-2 ">
                     @AppService.I18n.T("导出")
                    <AppChevronDown></AppChevronDown>
                </MButton>
            </ActivatorContent>
            <ChildContent>
                <MList>
                    <MListItem OnClick="()=>DownExportAsync(true)">@AppService.I18n.T("导出全部")</MListItem>
                        <MListItem OnClick="()=>DownExportAsync(false)">@AppService.I18n.T("导出搜索项")</MListItem>
                    </MList>
                </ChildContent>
            </MMenu>
        </OtherToolbarTemplate>

    </AppDataTable>



